/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package NetworkReceiver;
import FrameWork.Item;
import NetworkPackage.*;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
/**
 * this class is used to store queue of recieved items to be served in the room after that 
 * 
 */
public class JobScheduler {
    Queue<Item> jobQ;
    static JobScheduler instance;
    int state;
    JobScheduler()
    {
        jobQ = new ArrayBlockingQueue<Item>(100);
    }
    public static JobScheduler getInstance()
    {
        if(instance == null)
        {
            instance = new JobScheduler();
        }
        return instance;
    }
    public void addItem(Item item)  // add item in the queue
    {
        jobQ.add(item);
    }
    public Item deleteItem()        // return the head of the queue if exists and removes it or returns null if there is no items in the queue  
    {
        if(jobQ.isEmpty())
            return null;    //error
        return jobQ.remove();
    }
    public boolean hasItems()       // returns true if there are items in the queue 
    {
        return !(jobQ.isEmpty());
    }
}
